package com.wetao.lib_common.greendao.dao;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import com.wetao.lib_common.greendao.model.PenOffLineGridInfoChild;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "PEN_OFF_LINE_GRID_INFO_CHILD".
*/
public class PenOffLineGridInfoChildDao extends AbstractDao<PenOffLineGridInfoChild, Long> {

    public static final String TABLENAME = "PEN_OFF_LINE_GRID_INFO_CHILD";

    /**
     * Properties of entity PenOffLineGridInfoChild.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property GridId = new Property(1, Integer.class, "gridId", false, "GRID_ID");
        public final static Property GridType = new Property(2, Integer.class, "gridType", false, "GRID_TYPE");
        public final static Property Pageserial = new Property(3, String.class, "pageserial", false, "PAGESERIAL");
        public final static Property BookId = new Property(4, Integer.class, "bookId", false, "BOOK_ID");
        public final static Property PageNumber = new Property(5, Integer.class, "pageNumber", false, "PAGE_NUMBER");
        public final static Property SectionNo = new Property(6, Integer.class, "sectionNo", false, "SECTION_NO");
        public final static Property OwnerNo = new Property(7, Integer.class, "ownerNo", false, "OWNER_NO");
        public final static Property PageNum = new Property(8, Integer.class, "pageNum", false, "PAGE_NUM");
        public final static Property KnowledgeMapOutlineContentId = new Property(9, Integer.class, "knowledgeMapOutlineContentId", false, "KNOWLEDGE_MAP_OUTLINE_CONTENT_ID");
        public final static Property ContentType = new Property(10, Integer.class, "contentType", false, "CONTENT_TYPE");
        public final static Property ExamId = new Property(11, Integer.class, "examId", false, "EXAM_ID");
        public final static Property ExamName = new Property(12, String.class, "examName", false, "EXAM_NAME");
        public final static Property IsExam = new Property(13, Integer.class, "isExam", false, "IS_EXAM");
        public final static Property QuestionId = new Property(14, Integer.class, "questionId", false, "QUESTION_ID");
        public final static Property Question = new Property(15, String.class, "question", false, "QUESTION");
        public final static Property QuestionAnswer = new Property(16, String.class, "questionAnswer", false, "QUESTION_ANSWER");
        public final static Property FileName = new Property(17, String.class, "fileName", false, "FILE_NAME");
        public final static Property TotalPages = new Property(18, Integer.class, "totalPages", false, "TOTAL_PAGES");
        public final static Property Duration = new Property(19, Integer.class, "duration", false, "DURATION");
        public final static Property SetContent = new Property(20, String.class, "setContent", false, "SET_CONTENT");
        public final static Property StartX = new Property(21, Float.class, "startX", false, "START_X");
        public final static Property StartY = new Property(22, Float.class, "startY", false, "START_Y");
        public final static Property EndX = new Property(23, Float.class, "endX", false, "END_X");
        public final static Property EndY = new Property(24, Float.class, "endY", false, "END_Y");
        public final static Property ClassId = new Property(25, Integer.class, "classId", false, "CLASS_ID");
        public final static Property SourceNodeId = new Property(26, Integer.class, "sourceNodeId", false, "SOURCE_NODE_ID");
        public final static Property SpreadFlag = new Property(27, Integer.class, "spreadFlag", false, "SPREAD_FLAG");
        public final static Property BigPicWidth = new Property(28, Integer.class, "bigPicWidth", false, "BIG_PIC_WIDTH");
        public final static Property BigPicHeight = new Property(29, Integer.class, "bigPicHeight", false, "BIG_PIC_HEIGHT");
        public final static Property QuestionTypeId = new Property(30, Integer.class, "questionTypeId", false, "QUESTION_TYPE_ID");
        public final static Property PenOffLineGridInfoId = new Property(31, Long.class, "penOffLineGridInfoId", false, "PEN_OFF_LINE_GRID_INFO_ID");
    }

    private Query<PenOffLineGridInfoChild> penOffLineGridInfo_GridsQuery;

    public PenOffLineGridInfoChildDao(DaoConfig config) {
        super(config);
    }
    
    public PenOffLineGridInfoChildDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"PEN_OFF_LINE_GRID_INFO_CHILD\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"GRID_ID\" INTEGER," + // 1: gridId
                "\"GRID_TYPE\" INTEGER," + // 2: gridType
                "\"PAGESERIAL\" TEXT," + // 3: pageserial
                "\"BOOK_ID\" INTEGER," + // 4: bookId
                "\"PAGE_NUMBER\" INTEGER," + // 5: pageNumber
                "\"SECTION_NO\" INTEGER," + // 6: sectionNo
                "\"OWNER_NO\" INTEGER," + // 7: ownerNo
                "\"PAGE_NUM\" INTEGER," + // 8: pageNum
                "\"KNOWLEDGE_MAP_OUTLINE_CONTENT_ID\" INTEGER," + // 9: knowledgeMapOutlineContentId
                "\"CONTENT_TYPE\" INTEGER," + // 10: contentType
                "\"EXAM_ID\" INTEGER," + // 11: examId
                "\"EXAM_NAME\" TEXT," + // 12: examName
                "\"IS_EXAM\" INTEGER," + // 13: isExam
                "\"QUESTION_ID\" INTEGER," + // 14: questionId
                "\"QUESTION\" TEXT," + // 15: question
                "\"QUESTION_ANSWER\" TEXT," + // 16: questionAnswer
                "\"FILE_NAME\" TEXT," + // 17: fileName
                "\"TOTAL_PAGES\" INTEGER," + // 18: totalPages
                "\"DURATION\" INTEGER," + // 19: duration
                "\"SET_CONTENT\" TEXT," + // 20: setContent
                "\"START_X\" REAL," + // 21: startX
                "\"START_Y\" REAL," + // 22: startY
                "\"END_X\" REAL," + // 23: endX
                "\"END_Y\" REAL," + // 24: endY
                "\"CLASS_ID\" INTEGER," + // 25: classId
                "\"SOURCE_NODE_ID\" INTEGER," + // 26: sourceNodeId
                "\"SPREAD_FLAG\" INTEGER," + // 27: spreadFlag
                "\"BIG_PIC_WIDTH\" INTEGER," + // 28: bigPicWidth
                "\"BIG_PIC_HEIGHT\" INTEGER," + // 29: bigPicHeight
                "\"QUESTION_TYPE_ID\" INTEGER," + // 30: questionTypeId
                "\"PEN_OFF_LINE_GRID_INFO_ID\" INTEGER NOT NULL );"); // 31: penOffLineGridInfoId
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"PEN_OFF_LINE_GRID_INFO_CHILD\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, PenOffLineGridInfoChild entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Integer gridId = entity.getGridId();
        if (gridId != null) {
            stmt.bindLong(2, gridId);
        }
 
        Integer gridType = entity.getGridType();
        if (gridType != null) {
            stmt.bindLong(3, gridType);
        }
 
        String pageserial = entity.getPageserial();
        if (pageserial != null) {
            stmt.bindString(4, pageserial);
        }
 
        Integer bookId = entity.getBookId();
        if (bookId != null) {
            stmt.bindLong(5, bookId);
        }
 
        Integer pageNumber = entity.getPageNumber();
        if (pageNumber != null) {
            stmt.bindLong(6, pageNumber);
        }
 
        Integer sectionNo = entity.getSectionNo();
        if (sectionNo != null) {
            stmt.bindLong(7, sectionNo);
        }
 
        Integer ownerNo = entity.getOwnerNo();
        if (ownerNo != null) {
            stmt.bindLong(8, ownerNo);
        }
 
        Integer pageNum = entity.getPageNum();
        if (pageNum != null) {
            stmt.bindLong(9, pageNum);
        }
 
        Integer knowledgeMapOutlineContentId = entity.getKnowledgeMapOutlineContentId();
        if (knowledgeMapOutlineContentId != null) {
            stmt.bindLong(10, knowledgeMapOutlineContentId);
        }
 
        Integer contentType = entity.getContentType();
        if (contentType != null) {
            stmt.bindLong(11, contentType);
        }
 
        Integer examId = entity.getExamId();
        if (examId != null) {
            stmt.bindLong(12, examId);
        }
 
        String examName = entity.getExamName();
        if (examName != null) {
            stmt.bindString(13, examName);
        }
 
        Integer isExam = entity.getIsExam();
        if (isExam != null) {
            stmt.bindLong(14, isExam);
        }
 
        Integer questionId = entity.getQuestionId();
        if (questionId != null) {
            stmt.bindLong(15, questionId);
        }
 
        String question = entity.getQuestion();
        if (question != null) {
            stmt.bindString(16, question);
        }
 
        String questionAnswer = entity.getQuestionAnswer();
        if (questionAnswer != null) {
            stmt.bindString(17, questionAnswer);
        }
 
        String fileName = entity.getFileName();
        if (fileName != null) {
            stmt.bindString(18, fileName);
        }
 
        Integer totalPages = entity.getTotalPages();
        if (totalPages != null) {
            stmt.bindLong(19, totalPages);
        }
 
        Integer duration = entity.getDuration();
        if (duration != null) {
            stmt.bindLong(20, duration);
        }
 
        String setContent = entity.getSetContent();
        if (setContent != null) {
            stmt.bindString(21, setContent);
        }
 
        Float startX = entity.getStartX();
        if (startX != null) {
            stmt.bindDouble(22, startX);
        }
 
        Float startY = entity.getStartY();
        if (startY != null) {
            stmt.bindDouble(23, startY);
        }
 
        Float endX = entity.getEndX();
        if (endX != null) {
            stmt.bindDouble(24, endX);
        }
 
        Float endY = entity.getEndY();
        if (endY != null) {
            stmt.bindDouble(25, endY);
        }
 
        Integer classId = entity.getClassId();
        if (classId != null) {
            stmt.bindLong(26, classId);
        }
 
        Integer sourceNodeId = entity.getSourceNodeId();
        if (sourceNodeId != null) {
            stmt.bindLong(27, sourceNodeId);
        }
 
        Integer spreadFlag = entity.getSpreadFlag();
        if (spreadFlag != null) {
            stmt.bindLong(28, spreadFlag);
        }
 
        Integer bigPicWidth = entity.getBigPicWidth();
        if (bigPicWidth != null) {
            stmt.bindLong(29, bigPicWidth);
        }
 
        Integer bigPicHeight = entity.getBigPicHeight();
        if (bigPicHeight != null) {
            stmt.bindLong(30, bigPicHeight);
        }
 
        Integer questionTypeId = entity.getQuestionTypeId();
        if (questionTypeId != null) {
            stmt.bindLong(31, questionTypeId);
        }
        stmt.bindLong(32, entity.getPenOffLineGridInfoId());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, PenOffLineGridInfoChild entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Integer gridId = entity.getGridId();
        if (gridId != null) {
            stmt.bindLong(2, gridId);
        }
 
        Integer gridType = entity.getGridType();
        if (gridType != null) {
            stmt.bindLong(3, gridType);
        }
 
        String pageserial = entity.getPageserial();
        if (pageserial != null) {
            stmt.bindString(4, pageserial);
        }
 
        Integer bookId = entity.getBookId();
        if (bookId != null) {
            stmt.bindLong(5, bookId);
        }
 
        Integer pageNumber = entity.getPageNumber();
        if (pageNumber != null) {
            stmt.bindLong(6, pageNumber);
        }
 
        Integer sectionNo = entity.getSectionNo();
        if (sectionNo != null) {
            stmt.bindLong(7, sectionNo);
        }
 
        Integer ownerNo = entity.getOwnerNo();
        if (ownerNo != null) {
            stmt.bindLong(8, ownerNo);
        }
 
        Integer pageNum = entity.getPageNum();
        if (pageNum != null) {
            stmt.bindLong(9, pageNum);
        }
 
        Integer knowledgeMapOutlineContentId = entity.getKnowledgeMapOutlineContentId();
        if (knowledgeMapOutlineContentId != null) {
            stmt.bindLong(10, knowledgeMapOutlineContentId);
        }
 
        Integer contentType = entity.getContentType();
        if (contentType != null) {
            stmt.bindLong(11, contentType);
        }
 
        Integer examId = entity.getExamId();
        if (examId != null) {
            stmt.bindLong(12, examId);
        }
 
        String examName = entity.getExamName();
        if (examName != null) {
            stmt.bindString(13, examName);
        }
 
        Integer isExam = entity.getIsExam();
        if (isExam != null) {
            stmt.bindLong(14, isExam);
        }
 
        Integer questionId = entity.getQuestionId();
        if (questionId != null) {
            stmt.bindLong(15, questionId);
        }
 
        String question = entity.getQuestion();
        if (question != null) {
            stmt.bindString(16, question);
        }
 
        String questionAnswer = entity.getQuestionAnswer();
        if (questionAnswer != null) {
            stmt.bindString(17, questionAnswer);
        }
 
        String fileName = entity.getFileName();
        if (fileName != null) {
            stmt.bindString(18, fileName);
        }
 
        Integer totalPages = entity.getTotalPages();
        if (totalPages != null) {
            stmt.bindLong(19, totalPages);
        }
 
        Integer duration = entity.getDuration();
        if (duration != null) {
            stmt.bindLong(20, duration);
        }
 
        String setContent = entity.getSetContent();
        if (setContent != null) {
            stmt.bindString(21, setContent);
        }
 
        Float startX = entity.getStartX();
        if (startX != null) {
            stmt.bindDouble(22, startX);
        }
 
        Float startY = entity.getStartY();
        if (startY != null) {
            stmt.bindDouble(23, startY);
        }
 
        Float endX = entity.getEndX();
        if (endX != null) {
            stmt.bindDouble(24, endX);
        }
 
        Float endY = entity.getEndY();
        if (endY != null) {
            stmt.bindDouble(25, endY);
        }
 
        Integer classId = entity.getClassId();
        if (classId != null) {
            stmt.bindLong(26, classId);
        }
 
        Integer sourceNodeId = entity.getSourceNodeId();
        if (sourceNodeId != null) {
            stmt.bindLong(27, sourceNodeId);
        }
 
        Integer spreadFlag = entity.getSpreadFlag();
        if (spreadFlag != null) {
            stmt.bindLong(28, spreadFlag);
        }
 
        Integer bigPicWidth = entity.getBigPicWidth();
        if (bigPicWidth != null) {
            stmt.bindLong(29, bigPicWidth);
        }
 
        Integer bigPicHeight = entity.getBigPicHeight();
        if (bigPicHeight != null) {
            stmt.bindLong(30, bigPicHeight);
        }
 
        Integer questionTypeId = entity.getQuestionTypeId();
        if (questionTypeId != null) {
            stmt.bindLong(31, questionTypeId);
        }
        stmt.bindLong(32, entity.getPenOffLineGridInfoId());
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public PenOffLineGridInfoChild readEntity(Cursor cursor, int offset) {
        PenOffLineGridInfoChild entity = new PenOffLineGridInfoChild( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1), // gridId
            cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2), // gridType
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pageserial
            cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4), // bookId
            cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // pageNumber
            cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6), // sectionNo
            cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7), // ownerNo
            cursor.isNull(offset + 8) ? null : cursor.getInt(offset + 8), // pageNum
            cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9), // knowledgeMapOutlineContentId
            cursor.isNull(offset + 10) ? null : cursor.getInt(offset + 10), // contentType
            cursor.isNull(offset + 11) ? null : cursor.getInt(offset + 11), // examId
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // examName
            cursor.isNull(offset + 13) ? null : cursor.getInt(offset + 13), // isExam
            cursor.isNull(offset + 14) ? null : cursor.getInt(offset + 14), // questionId
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // question
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // questionAnswer
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // fileName
            cursor.isNull(offset + 18) ? null : cursor.getInt(offset + 18), // totalPages
            cursor.isNull(offset + 19) ? null : cursor.getInt(offset + 19), // duration
            cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // setContent
            cursor.isNull(offset + 21) ? null : cursor.getFloat(offset + 21), // startX
            cursor.isNull(offset + 22) ? null : cursor.getFloat(offset + 22), // startY
            cursor.isNull(offset + 23) ? null : cursor.getFloat(offset + 23), // endX
            cursor.isNull(offset + 24) ? null : cursor.getFloat(offset + 24), // endY
            cursor.isNull(offset + 25) ? null : cursor.getInt(offset + 25), // classId
            cursor.isNull(offset + 26) ? null : cursor.getInt(offset + 26), // sourceNodeId
            cursor.isNull(offset + 27) ? null : cursor.getInt(offset + 27), // spreadFlag
            cursor.isNull(offset + 28) ? null : cursor.getInt(offset + 28), // bigPicWidth
            cursor.isNull(offset + 29) ? null : cursor.getInt(offset + 29), // bigPicHeight
            cursor.isNull(offset + 30) ? null : cursor.getInt(offset + 30), // questionTypeId
            cursor.getLong(offset + 31) // penOffLineGridInfoId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, PenOffLineGridInfoChild entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setGridId(cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1));
        entity.setGridType(cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2));
        entity.setPageserial(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setBookId(cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4));
        entity.setPageNumber(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
        entity.setSectionNo(cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6));
        entity.setOwnerNo(cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7));
        entity.setPageNum(cursor.isNull(offset + 8) ? null : cursor.getInt(offset + 8));
        entity.setKnowledgeMapOutlineContentId(cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9));
        entity.setContentType(cursor.isNull(offset + 10) ? null : cursor.getInt(offset + 10));
        entity.setExamId(cursor.isNull(offset + 11) ? null : cursor.getInt(offset + 11));
        entity.setExamName(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setIsExam(cursor.isNull(offset + 13) ? null : cursor.getInt(offset + 13));
        entity.setQuestionId(cursor.isNull(offset + 14) ? null : cursor.getInt(offset + 14));
        entity.setQuestion(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setQuestionAnswer(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setFileName(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
        entity.setTotalPages(cursor.isNull(offset + 18) ? null : cursor.getInt(offset + 18));
        entity.setDuration(cursor.isNull(offset + 19) ? null : cursor.getInt(offset + 19));
        entity.setSetContent(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
        entity.setStartX(cursor.isNull(offset + 21) ? null : cursor.getFloat(offset + 21));
        entity.setStartY(cursor.isNull(offset + 22) ? null : cursor.getFloat(offset + 22));
        entity.setEndX(cursor.isNull(offset + 23) ? null : cursor.getFloat(offset + 23));
        entity.setEndY(cursor.isNull(offset + 24) ? null : cursor.getFloat(offset + 24));
        entity.setClassId(cursor.isNull(offset + 25) ? null : cursor.getInt(offset + 25));
        entity.setSourceNodeId(cursor.isNull(offset + 26) ? null : cursor.getInt(offset + 26));
        entity.setSpreadFlag(cursor.isNull(offset + 27) ? null : cursor.getInt(offset + 27));
        entity.setBigPicWidth(cursor.isNull(offset + 28) ? null : cursor.getInt(offset + 28));
        entity.setBigPicHeight(cursor.isNull(offset + 29) ? null : cursor.getInt(offset + 29));
        entity.setQuestionTypeId(cursor.isNull(offset + 30) ? null : cursor.getInt(offset + 30));
        entity.setPenOffLineGridInfoId(cursor.getLong(offset + 31));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(PenOffLineGridInfoChild entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(PenOffLineGridInfoChild entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(PenOffLineGridInfoChild entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "grids" to-many relationship of PenOffLineGridInfo. */
    public List<PenOffLineGridInfoChild> _queryPenOffLineGridInfo_Grids(Long penOffLineGridInfoId) {
        synchronized (this) {
            if (penOffLineGridInfo_GridsQuery == null) {
                QueryBuilder<PenOffLineGridInfoChild> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.PenOffLineGridInfoId.eq(null));
                penOffLineGridInfo_GridsQuery = queryBuilder.build();
            }
        }
        Query<PenOffLineGridInfoChild> query = penOffLineGridInfo_GridsQuery.forCurrentThread();
        query.setParameter(0, penOffLineGridInfoId);
        return query.list();
    }

}
